package com.example.design.bilibili.prototype.deep.serialize;

public class Client {

    public static void main(String[] args) throws Exception{
        DeepPrototypeType p = new DeepPrototypeType();
        p.name = "宋江";
        p.deepCloneableTarget = new DeepCloneableTarget("大牛","小牛");

        //方式1：完成深拷贝
        DeepPrototypeType p2 = (DeepPrototypeType)p.clone();

        System.out.println("p.name="+p.name+",p.deepCloneableTarget = "+p.deepCloneableTarget.hashCode());
        System.out.println("p2.name="+p2.name+",p2.deepCloneableTarget = "+p2.deepCloneableTarget.hashCode());

        System.out.println("===============================================================================");

        //方式2：完成深拷贝

        DeepPrototypeType p3 = (DeepPrototypeType) p.deepClone();
        System.out.println("p.name="+p.name+",p.deepCloneableTarget = "+p.deepCloneableTarget.hashCode());
        System.out.println("p3.name="+p3.name+",p3.deepCloneableTarget = "+p3.deepCloneableTarget.hashCode());
    }
}
